package me.leiusual.sharing.ui.order.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import me.leiusual.sharing.ui.order.OrderListFragment

/**
 * author: leiusual
 * create on: 2019-07-31
 * description:
 */
class OrderHomeAdapter(
    private val storeId: Long,
    fragmentManager: FragmentManager
) : FragmentStatePagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

  private val dataSet = listOf("待付款", "待发货", "待收货", "所有订单")

  override fun getCount(): Int {
    return dataSet.size
  }

  override fun getPageTitle(position: Int): CharSequence? {
    return dataSet[position]
  }

  override fun getItem(position: Int): Fragment {
    val status = when (position) {
      0 -> 1
      1 -> 2
      2 -> 3
      else -> 0
    }
    return OrderListFragment.newInstance(storeId, status)
  }
}